//
//  UIButton+Extension.swift
//  LXTXShop
//
//  Created by apple on 2018/4/9.
//  Copyright © 2018年 LX. All rights reserved.
//

import UIKit

private var bObjAssociationKey: UInt8 = 0

extension UIButton {
    var bObj: NSObject! {
        get {
            return objc_getAssociatedObject(self, &bObjAssociationKey) as? NSObject
        }
        set(bObjValue) {
            objc_setAssociatedObject(self, &bObjAssociationKey, bObjValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
        }
    }
    
    class func sizeOfLabel(customMaxWidth: CGFloat,systemFontSize: CGFloat,filledTextString: String) -> CGSize {
        
        let label = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: customMaxWidth, height: 0))
        label.text = filledTextString
        label.numberOfLines = 0
        label.font = UIFont.systemFont(ofSize: systemFontSize)
        label.sizeToFit()
        
        let size = label.frame.size
        
        return size
    }
}
